<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/include/pageExpires.jsp"%>
<%@ include file="/common/include/taglibs.jsp"%>
<%@ page import="com.kylin.module.shop.orm.*,
                 java.util.*,
				 com.kylin.hibernate.*" %>

<%
    List pList = (List)session.getAttribute("MyPList");
    if(pList == null)
        pList = new ArrayList();
        
    String [] addIds = request.getParameterValues("ids");
    if(addIds!=null){// 添加到询盘
	    for(int i=0;i< addIds.length; i++){
	    	boolean has = false;
	        for(int j=0;j<pList.size();j++){
	            Product exist = (Product)pList.get(j);
	            if(exist.getId().equals(new Long(addIds[i])) ){
	            	has =true;
	            }
	        }
	        if(has)
	            continue;
	        Product p = (Product)BaseHibernateDAO.findById(Product.class,new Long(addIds[i]));
	        pList.add(p);
	    }
    }
    
    String [] delIds = request.getParameterValues("delIds");
    if(delIds!=null){//从询盘删除
	    for(int i=0;i< delIds.length; i++){
	    	boolean has = false;
	        for(int j=0;j<pList.size();j++){
	            Product exist = (Product)pList.get(j);
	            if(exist.getId().equals(new Long(delIds[i])) )
	            	pList.remove(j);
	        }
	    }
    }
    session.setAttribute("MyPList",pList);
    
%>
<form action="/module/shop/_nodeco/addPlist.jsp" name="removeForm" method="post">
<input type="submit" value="移除" >
<table border=1>
<tr><td>询盘列表</td></tr>
<%    
    for(int i=0;i<pList.size();i++){
    	Product p = (Product)pList.get(i);
%>
    <tr><td>
    <input type="checkbox" name="delIds" value="<%=p.getId() %>" >
    <%= pList.get(i)%>
	</td></tr>
<%       
    }
%>
</table>
</form>
			     